<!--
 * @description:  
 * @author: sleep
 * @Date: 2024-01-28 20:44:16
 * @LastEditors: zhaoqiang zhaoqiang@qq.com
 * @LastEditTime: 2024-01-28 21:06:39
-->
<template>
	<view class="">
		<view class="contina w">
			<template v-for="(item, idx) in list">
				<view class="item flex_a_c " :key="idx" :class="corp_id == item.id ? 'acvItem' : 'noacItem'" @click="sele(item)">
					<view class="imgBgc">
						<image src="../../static/image/company-fill.png" />
					</view>
					<view class="title">
						<view class="name">
							{{item.name}}
						</view>
						<view class="time">
							服务期限：{{item.forever?'永久':(item.duration_start?item.duration_start+' - '+item.duration_end:'')}}
						</view>
					</view>
				</view>
			</template>
		</view>
		<flooterCom text="创建新企业"></flooterCom>
	</view>
</template>

<script>
	import flooterCom from "@/compoment/flooterCom.vue"
	export default {
		data() {
			return {
				list:[],
				page:1,
				corp_id:0
			}
		},
		onLoad(option) {
			this.corp_id = option.corp_id
		},
		onShow() {
			this.getList()
		},
		components:{flooterCom},
		methods: {
			sele(item) {
				this.$api.homeApi.setCorp({corp_id:item.id}).then((res)=>{					
					uni.$emit('select_corp',item)
					uni.navigateBack()
				})
			},
			async getList(){
				let res = await this.$api.homeApi.getCorpList({page:this.page})
				if(res.list.length){
					this.list = this.list.concat(res.list)
					this.page++
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F8F8F8;
	}
	.contina{
		padding-bottom: 140rpx;
	}
	.acvItem {
		background-color: #EEF7FE;
		border: 1px solid #0074FF;
		position: relative;
	}

	.acvItem::before {
		content: "当前";
		position: absolute;
		text-align: center;
		top: 0;
		left: 0;
		width: 68rpx;
		height: 34rpx;
		background: #0074FF;
		color: #fff;
		font-size: 24rpx;
		border-radius: 5px 0px 5px 0px;
	}

	.noacItem {
		background: #FFFFFF;
	}

	.item {
		height: 180rpx;
		border-radius: 5px 5px 5px 5px;
		margin-top: 20rpx;
		padding: 30rpx;
		display: flex;
		box-sizing: border-box;

		.imgBgc {
			width: 120rpx;
			height: 120rpx;
			border-radius: 50%;
			background: #D6E4FF;
			display: flex;
			justify-content: center;
			align-items: center;

			image {
				width: 80%;
				height: 80%;
			}
		}

		.title {
			margin-left: 20rpx;

			.name {
				font-size: 28rpx;
				font-weight: 400;
				color: #000000;
				margin-top: 12rpx;
			}

			.time {
				font-size: 24rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color: #888888;
				margin-top: 20rpx;
			}
		}
	}
</style>